/**
 * @fileOverview *************************
 * @version 0.0.5
 */
/* ----------------------------------------------------------------------------------- */

var JXHDLIB = {};


JXHDLIB.previewWindowName = "ContentPrintPreviewWindow";



/* ----------------------------------------------------------------------------------- */


JXHDLIB.SmoothScroll = function () {

	this.selector    = $('a[href^=#], area[href^=#]');

	this.goToPageTop = "#headerContainer";

	this.speed       = 600;

	this.easing      = "easeOutExpo";

	this.noScrollCName    = "no-scroll";

	if (this.selector.length && window.name != JXHDLIB.previewWindowName) {
		this.init();
	}
}

JXHDLIB.SmoothScroll.prototype.init = function () {
	var _this = this;
	this.selector.each(function () {
		if (!$(this).hasClass(_this.noScrollCName)) {
			var fi = $(this).attr("href");
			if (fi == "#") return false;
			var el = ($(fi).length) ? $(fi) : $("a[name="+fi.replace(/#/,"")+"]");
			if (el.length) {
				$(this).click(function() {
					//e.preventDefault();
					var target = el[0];
					$.scrollTo(target, {
						speed: _this.speed,
						easing: _this.easing/*,
						onAfter: function() {
							return (fi == _this.goToPageTop) ? false : true;
						}*/
					});
					return (fi == _this.goToPageTop) ? false : true;
				});
			}
		}
	});
}

/* ----------------------------------------------------------------------------------- */

JXHDLIB.SearchPlaceholder = function () {

	this.d_fcolor = "#8a8a8a";

	this.fcolor = "#555555";

	this.formData = [
						{
							target : "#bizsearchAspQuery",
							defaultKeyword : "サイト内検索"
						},
						{
							target : "#content-search",
							defaultKeyword : "サイト内検索"
						}
					];
//	if () {
		this.init();
//	}
}

JXHDLIB.SearchPlaceholder.prototype.init = function () {
	var _this = this;
	$.each(_this.formData, function (i) {
		var d_key = this.defaultKeyword;
		$(this.target).each(function () {
			var el = $(this);
			el.css({"color" : _this.d_fcolor})
				.attr({"value"  : d_key});

			el.focus(function () {
				if (el.attr("value") == d_key) {
					el.attr({"value" : ""});
				}
				el.css({"color" : _this.fcolor});
			});

			el.blur(function () {
				if (el.attr("value") == "") {
					el.css({"color" : _this.d_fcolor})
						.attr({"value"  : d_key});
				}
			});
		});

	});
}


/* ----------------------------------------------------------------------------------- */
$(function() {

	if (jQuery.browser.msie && jQuery.browser.version == 6) {
		try {
			document.execCommand("BackgroundImageCache", false, true);
		} catch(err) {}
	}

	var roi = new RolloverImages('rollover', 'on');

	for (module in JXHDLIB) {
		var obj = JXHDLIB[module];
		if (obj && typeof obj == "function") {
			new JXHDLIB[module]();
		}
	}

});


/*---------------------------------------------------------------------------*/
if(typeof StyleSwitcher != 'undefined') {
	FONTSIZE_SELECTOR_ENABLED = true;
	FONTSIZE_SELECTOR         = null;
	
	
	if (FONTSIZE_SELECTOR_ENABLED) {
	
		$(function() {
			var config = {
				className      : "fontsize",
				blockId        : "fontsize-selector",
				buttonsSetting : {
						"default" : {
									styleId       : "fontsize-default",
									buttonId      : "fontsize-btn-default"
						},
						"large" : {
									styleId       : "fontsize-large",
									buttonId      : "fontsize-btn-large"
						}
				}
				,rollover : new RolloverImages("rollover-fsbutton", "on", "on")
			};
	
			FONTSIZE_SELECTOR = new FontSizeSelector(config);
		});
	
		// 
		document.write(''
		+ '<style  type="text/css" media="screen,print">'
		+ '#fontsize-selector {display: block !important;}'
		+ '</style>');
	}
	



}

/*---------------------------------------------------------------------------*/
//OS
var mac = (navigator.appVersion.indexOf("Mac") != -1)? true : false;
var win = (navigator.appVersion.indexOf("Win") != -1)? true : false;

//browser
var nn = (navigator.appName.indexOf("Netscape",0) != -1)? true : false;
var nn4 = (document.layers)? true : false;
var opera6 = (navigator.userAgent.indexOf("Opera/6") != -1)? true : false;
var opera5 = (navigator.userAgent.indexOf("Opera/5") != -1)? true : false;
var icab = (navigator.userAgent.indexOf("iCab") != -1)? true : false;
var ie = (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0)? true : false;
var ie4 = navigator.userAgent.indexOf("MSIE 4") != -1;
var ie5 = (navigator.userAgent.indexOf("MSIE 5") != -1)? true : false;


var newWindow;
var index = 0;

function openFigWindow(targetObj,windowW,windowH,scrollbarOption){
	var windowName = targetObj.target;
	var uri = targetObj.href;
	
	if(scrollbarOption && opera6){
		windowW = windowW -15;
	}
	if(scrollbarOption && win && ie){
		windowW = windowW +15;
	}
	
	var options = 'toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=' + (scrollbarOption?'yes':'no') + ',resizable=yes,width=' + windowW + ',height=' + windowH;
	
	if(!window.scrollbars){
		//if(scrollbarOption)windowName += '_02';
	}
	
	newWindow = window.open(uri,windowName,options);
	newWindow.focus();
	
	if(newWindow.scrollbars){
		if(scrollbarOption){
			newWindow.scrollbars.visible = true;
		}
		else{
			newWindow.scrollbars.visible = false;
		}
	}
}